<html>
	<title>ZForms.Value.Multiple</title>
	<head>
		<script type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
		<script type="text/javascript" src="/js/Common.js"></script>
		<script type="text/javascript" src="/sources/ZForms.js"></script>
		<script type="text/javascript" src="/sources/ZForms/Value.js"></script>
		<script type="text/javascript" src="/sources/ZForms/Value/Multiple.js"></script>
	</head>
	<body>
		<h1>ZForms.Value.Multiple</h1>
	</body>
	<script type="text/javascript">

	function testGet() {

		var oValue = new ZForms.Value.Multiple([]);
		assertTrue('get 1', oValue.get().length == 0);

		oValue = new ZForms.Value.Multiple([2, 3]);
		assertTrue('get 2', oValue.get().length == 2);
		assertTrue('get 3', oValue.get()[0] == 2);
		assertTrue('get 4', oValue.get()[1] == 3);

		oValue = new ZForms.Value.Multiple();
		assertTrue('get 5', oValue.get().length == 0);

	}

	function testSet() {

		var oValue = new ZForms.Value.Multiple();
		oValue.set([]);
		assertTrue('set 1', oValue.get().length == 0);

		oValue.set([2, 3]);
		assertTrue('set 2', oValue.get().length == 2);
		assertTrue('set 3', oValue.get()[0] == 2);
		assertTrue('set 4', oValue.get()[1] == 3);				

	}

	function testReset() {

		var oValue = new ZForms.Value.Multiple(['test']);
		oValue.reset();
		assertTrue('reset', oValue.get().length == 0);
	}

	function testMatch() {

		var oValue = new ZForms.Value.Multiple([44,3]);
		assertTrue('match 1', oValue.match(/\d+/));
		assertFalse('match 2', oValue.match(/\d{3,}/));

	}

	function testIsEmpty() {

		var oValue = new ZForms.Value.Multiple();
		assertTrue('is empty 1', oValue.isEmpty());

		oValue.set('');
		assertFalse('is empty 2', oValue.isEmpty());

		oValue.set(0);
		assertFalse('is empty 3', oValue.isEmpty());

		oValue.set([]);
		assertTrue('is empty 4', oValue.isEmpty());

	}

	function testIsEqual() {

		var oValue = new ZForms.Value.Multiple([1, 2]);
		assertTrue('is equal 1', oValue.isEqual(new ZForms.Value.Multiple([1, 2])));
		assertFalse('is equal 2', oValue.isEqual(new ZForms.Value.Multiple([2, 1])));
		assertTrue('is equal 3', oValue.isEqual([1, 2]));
		assertFalse('is equal 4', oValue.isEqual('5'));
		assertFalse('is equal 5', oValue.isEqual(5));

		oValue.set([5]);
		assertTrue('is equal 6', oValue.isEqual(5));

	}

	function testIsGreater() {

		var oValue = new ZForms.Value.Multiple([2, 3]);
		assertTrue('is greater 1', oValue.isGreater(new ZForms.Value.Multiple([2])));
		assertTrue('is greater 2', oValue.isGreater([]));
		assertFalse('is greater 3', oValue.isGreater([3,4]));
		assertFalse('is greater 4', oValue.isGreater(new ZForms.Value.Multiple([3,20,23])));		
		assertFalse('is greater 7', oValue.isGreater(null));

	}

	function testIsGreaterOrEqual() {

		var oValue = new ZForms.Value.Multiple([2, 3]);
		assertTrue('is greater or equal 1', oValue.isGreaterOrEqual(new ZForms.Value.Multiple([2])));
		assertTrue('is greater or equal 2', oValue.isGreaterOrEqual([]));
		assertTrue('is greater or equal 3', oValue.isGreaterOrEqual([2,3]));
		assertFalse('is greater or equal 4', oValue.isGreaterOrEqual(new ZForms.Value.Multiple([3,20,23])));
		assertFalse('is greater or equal 7', oValue.isGreaterOrEqual(null));

	}

	function testIsLess() {

		var oValue = new ZForms.Value.Multiple([2, 3]);
		assertTrue('is less 1', oValue.isLess(new ZForms.Value.Multiple([2, 3, 4])));
		assertFalse('is less 2', oValue.isLess(new ZForms.Value.Multiple([2, 3])));
		assertFalse('is less 3', oValue.isLess(new ZForms.Value.Multiple([2])));
		assertFalse('is less 4', oValue.isLess('ts'));
		assertFalse('is less 5', oValue.isLess(''));
		assertFalse('is less 6', oValue.isLess(new ZForms.Value(2)));

	}

	function testIsLessOrEqual() {

		var oValue = new ZForms.Value.Multiple([2, 3]);
		assertTrue('is less or equal 1', oValue.isLessOrEqual(new ZForms.Value.Multiple([2, 3, 4])));
		assertTrue('is less or equal 2', oValue.isLessOrEqual(new ZForms.Value.Multiple([2, 3])));
		assertFalse('is less or equal 3', oValue.isLessOrEqual(new ZForms.Value.Multiple([2])));
		assertFalse('is less or equal 4', oValue.isLessOrEqual('ts'));
		assertFalse('is less or equal 5', oValue.isLessOrEqual(''));
		assertFalse('is less or equal 6', oValue.isLessOrEqual(new ZForms.Value(2)));

	}

	function testToStr() {

		var oValue = new ZForms.Value.Multiple([2, 3.23, 'test']);
		assertEquals('to str 1', oValue.toStr(), '2,3.23,test');

		oValue.set('test');
		assertEquals('to str 2', oValue.toStr(), 'test');

	}

	</script>
</html>